#include "funcs.h"
#define NUM_OF_NVICTYPE  18
void Delay(__IO uint32_t nCount)
{
	for(; nCount !=0;nCount--);
}
void GBKtoHex(char c) {
	char high = (c >> 4) & 0x0F, low = c & 0x0F;
	high = high < 10 ? high + '0' : high + 'A' - 10;
	low = low < 10 ? low + '0' : low + 'A' - 10; 
} 

void HextoGBK()
{
	
}

 void NVIC_DisableIRQ_user(IRQn_Type IRQn)
{
  NVIC->ICER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* disable interrupt */
}
void NVIC_EnableIRQ_user(IRQn_Type IRQn)
{
  NVIC->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* enable interrupt */
}
void __disableAllNvic()
{
	uint8_t i = 0;
	NVIC_DisableIRQ_user(CAN1_RX1_IRQn);
	for(i = 0;i<NUM_OF_NVICTYPE;++i)
	{
		NVIC_DisableIRQ_user((IRQn_Type)i);
	}
}

void __enableAllNvic()
{
	uint8_t i = 0;
	for(i = 0;i<NUM_OF_NVICTYPE;++i)
	{
		NVIC_EnableIRQ_user((IRQn_Type)i);
	}
}

extern uint8_t dlyflg;
extern uint32_t delaycnt;
void stmDelay(uint32_t time)
{
	static uint8_t non_reentrant = 0u;
	non_reentrant++;
	if(non_reentrant>1)
	{
		non_reentrant = 0;
		return;
	}
	dlyflg = 1;
	/*delaycnt每ms执行一次*/
	while(delaycnt<time);
	delaycnt = 0u;
	dlyflg = 0u; 
}


